package com.bluemoon.bmwalk.common.jacoco.dto;

import static com.bluemoon.bmwalk.common.jacoco.JacocoXmlConstant.COUNTER;
import static com.bluemoon.bmwalk.common.jacoco.JacocoXmlConstant.LINE;
import static com.bluemoon.bmwalk.common.jacoco.JacocoXmlConstant.SESSIONINFO;

import java.util.ArrayList;
import java.util.List;

import lombok.Data;

/***
	<sourcefile name="TestDTO.java">
		<line nr="10" mi="145" ci="15" mb="30" cb="0" />
		<line nr="15" mi="0" ci="3" mb="0" cb="0" />
		<line nr="17" mi="3" ci="0" mb="0" cb="0" />
		<line nr="19" mi="3" ci="0" mb="0" cb="0" />
		<counter type="INSTRUCTION" missed="151" covered="18" />
		<counter type="BRANCH" missed="30" covered="0" />
		<counter type="LINE" missed="2" covered="2" />
		<counter type="COMPLEXITY" missed="21" covered="5" />
		<counter type="METHOD" missed="6" covered="5" />
		<counter type="CLASS" missed="0" covered="1" />
	</sourcefile>
 * @author: liaozhioyng
 * @create: 2024-01-03
 */
@Data
public class Sourcefile {

    private String name;

    private final List<Counter> sourcefileCounters = new ArrayList<>();

    private final List<Line> lines = new ArrayList<>();

    public void addCounter(Counter counter) {
    	sourcefileCounters.add(counter);
    }

    public void addLines(Line line) {
    	lines.add(line);
    }
    
    public static void main(String[] args) {
    	Sourcefile sf = new Sourcefile();
    	String qName = SESSIONINFO;
    	Line line = null;
    	 switch (qName) {
	         // 跳过 sessioninfo 和 line
	         case SESSIONINFO:
	        	 line = new Line();
	        	 line.setNr(1);
	        	 sf.addLines(line);
//	             return;
	             break;
	         case COUNTER:
	             break;
	         case LINE:
	             break;
	         default:
	             break;
	     }
    	 line.setCb(2);
    	 line = null;
    	 for (Line e : sf.getLines()) {
        	 System.out.println(e);
		}
    	 System.out.println(qName);
	}
    
}
